<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
-->
<%@page import="com.ckeditor.SamplePostData"%>
<%@page import="com.ckeditor.CKPaginationSupport"%>
<%@page import="com.ckeditor.AutoUploadFileForCKEditor"%>
<%@page import="java.util.*"%>
<%@page language="Java" contentType="text/html; charset=GBK" pageEncoding="UTF-8"%>

<%
	request.setCharacterEncoding("utf-8");
	String s = request.getParameter("fileUpload");
	String serverRootPath = request.getSession().getServletContext().getRealPath("/");
	String uploadFolder = serverRootPath + "ckeditor/uploader/upload/autouploadfiles/";
	s = AutoUploadFileForCKEditor.autoUploadFileAndReplaceSourceSrc(uploadFolder,s);
	
	String[] sArray = CKPaginationSupport.seperateContentToPages(s);
	int pageCount = sArray.length;
	int currPage = 1;
	if(request.getParameter("currPage") != null) {
		currPage = Integer.parseInt(request.getParameter("currPage"));
	}
	//System.out.println("pageCount = " + pageCount);
%>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Sample &mdash; CKEditor</title>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
	<link type="text/css" rel="stylesheet" href="ckeditor/_samples/sample.css" />
	
</head>
<body onload="init()">
	<h1 class="samples">
		CKEditor &mdash; Posted Data
	</h1>
	<table border="1" cellspacing="0" id="outputSample">
		<colgroup><col width="100" /></colgroup>
		<thead>
			<tr>
				<th>Field&nbsp;Name</th>
				<th>Value</th>
			</tr>
		</thead>
	<%
		out.write(new SamplePostData(request).getAllFormFieldsAndValues());
	%>
	</table>
	
	<textarea cols="80" id="content" name="fileUpload"><%=s%></textarea>
	
<script type="text/javascript">  
	CKEDITOR.replace("content");
	var editor = CKEDITOR.instances.content;
	editor.focus();
</script>
	<br/><br/><br/>
		<%=sArray[currPage-1]%><br/>
		<%
			if(pageCount > 1) {
		%>
			<a href="javascript:gotoPage(1)">上一页</a>	1 2 3 4 5	下一页
		<%
			}
		%>
	
</body>
</html>


<script>

	//分页的实现
	function prePage() {
		
	}
	
	function nextPage() {
		
	}
	
	function firstPage() {
		
	}
	
	function lastPage() {
		
	}
	
	//跳页
	function gotoPage(pageNum) {
		//alert(window.location.href);
		var currpage = "<%=currPage%>"
		var local = window.location.href;
		if(local.indexOf("?")>0) {
			local = local.substring(0,local.indexOf("currPage=")+9) + pageNum;
		}else {
			local = local + "?currPage=" + pageNum;
		}
		alert(local);
		window.location.href = local;
	}
</script>
